﻿namespace Tools
{
    /// <summary>
    /// 只读的信号监听
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ReadOnlyReactiveProperty<T> : ReactiveProperty<T>
    {
        public new T Value => _value;

        public ReadOnlyReactiveProperty(T initialValue) : base(initialValue)
        {
        }

        /// <summary>
        /// 谨慎调用
        /// </summary>
        /// <param name="value"></param>
        public void SetValue(T value)
        {
            if (!EqualityComparer.Equals(this._value, value))
            {
                SetValueAndForceDispath(value);
            }
        }
    }
}